<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="__ROOT__/layui/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="__ROOT__/layui/lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
    <link rel="stylesheet" href="__ROOT__/layui/css/public.css" media="all">
    <style type="text/css">
        .layui-table-cell {
            height: auto;
             /*overflow:visible; text-overflow:inherit; white-space:normal;*/
        }
    </style>
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <fieldset class="table-search-fieldset">
            <legend>搜索信息</legend>
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">项目编号</label>
                            <div class="layui-input-inline">
                                <input type="text" name="num" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">项目关键词</label>
                            <div class="layui-input-inline">
                                <input type="text" name="name" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">编程语言</label>
                            <div class="layui-input-inline">
                                <input type="text" name="language" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">技术领域</label>
                            <div class="layui-input-inline">
                                <input type="text" name="field" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-primary"  lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>



        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
        <script type="text/html" id="currentTableBar">
            <a class="layui-btn  layui-btn-normal layui-btn-xs data-count-advance " lay-event="advance"><i class="fa fa-exchange"></i></a>
            <a class="layui-btn layui-btn-green layui-btn-xs data-count-see " lay-event="see"><i class="fa fa-folder-open-o"></i></a>
            <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete " lay-event="delete"><i class="fa fa-trash-o"></i></a>
            <a class="layui-btn layui-btn-xs layui-btn-warm data-count-user "  lay-event="user"><i class="fa fa-user"></i></a>
            <a class="layui-btn layui-btn-xs layui-bg-blue data-count-developer " lay-event="developer"><i class="fa fa-user-secret"></i></a>
            {{#  if((d.developerId1 >1)){ }}
            <a class="layui-btn layui-btn-xs layui-bg-blue data-count-developer " lay-event="developer1"><i class="fa fa-user-secret"></i></a>
            {{#  } else { }}

            {{#  } }}
        </script>

    </div>
</div>
<script src="__ROOT__/layui/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script type="text/html" id="titleTpl">
    {{#  if(d.first_fee_state == '首款已申请'){ }}
    <a href=""  class="first" attr-id="{{d.id}}" style="margin-left: 10px;color: red">首款申请</a>
    {{#  } else if(d.first_fee_state == '首款已支付') { }}
    <a href=""  class="first" attr-id="{{d.id}}" style="margin-left: 10px;color: green">首款已付</a>
    {{#  } else { }}

    {{#  } }}


    {{#  if(d.end_fee_state == '尾款已申请'){ }}
    <a href=""  class="end" attr-id="{{d.id}}" style="margin-left: 10px;color: red">尾款申请</a>
    {{#  } else if(d.end_fee_state == '尾款已支付') { }}
    <a href=""  class="end" attr-id="{{d.id}}" style="margin-left: 10px;color: green">尾款已付</a>
    {{#  } else { }}

    {{#  } }}
</script>

<script type="text/html" id="Tpl">
    {{#  if(d.state == '待接单'){ }}
    <span class="layui-badge">待接单</span>
    {{#  } else if(d.state == '开发中') { }}
    <span class="layui-badge layui-bg-orange">开发中</span>
    {{#  } else if(d.state == '售后中') { }}
    <span class="layui-badge layui-bg-blue">售后中</span>
    {{#  } else if(d.state == '已完成') { }}
    <span class="layui-badge layui-bg-green">已完成</span>
    {{#  } else if(d.state == '已取消') { }}
    <span class="layui-badge-rim">已取消</span>
    {{#  } else { }}

    {{#  } }}

</script>
<script>
    layui.use(['form', 'table'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table;

        table.render({
            elem: '#currentTableId',
            url: '/index.php/index/order/get_order',
            cols: [[
                {field: 'num', width:80, title: '编号', sort: true},
                {field: 'name',width:400, title: '项目名称', sort: true,templet:'<div>{{d.name}}<span class="layui-badge layui-bg-blue "  style="margin-left: 10px">{{d.industry}}</span></div>'},
                {field: 'name', title: '语言/领域/平台', sort: true ,templet: '<div>{{d.language}}/{{d.field}}/{{d.platform}}</div>'},
                {field: 'developerFee',  title: '开发费',width:80},
                {field: 'developerTotal',  title: '总费用',width:80},
                {field: 'state',width:100, title: '项目状态', sort: true,templet: '#Tpl'},
                {field: 'state',width:150, title: '付款状态', sort: true,templet: '#titleTpl'},
                {field: 'completeTime',width:130, title: '项目要求时间', sort: true},
                {field: 'beizhu', title: '客户备注'},
                {field: 'admin_beizhu', title: '客服备注'},
                {title: '操作',width:235, toolbar: '#currentTableBar', align: "left" }
            ]],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 20,
            page: true
            ,size: 'sm' //小尺寸的表格
        });

        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            var result = JSON.stringify(data.field);


            //执行搜索重载
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: {
                    searchParams: result
                }
            }, 'data');

            return false;
        });

        /**
         * toolbar监听事件
         */


        table.on('tool(currentTableFilter)', function (obj) {
            var mdata = obj.data;
       
            if (obj.event === 'advance') {

                var index = layer.open({
                    title: '推进项目',
                    type: 2,
                    shade: 0.2,
                    maxmin:true,
                    shadeClose: true,
                    area: ['60%', '80%'],
                    content: '/index.php/index/order/step?id='+mdata.id,
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
                return false;
            } else if (obj.event === 'delete') {
                layer.confirm('真的要取消订单吗', function (index) {
                    var url = "{:url('order/del')}";
                    var data={'id':mdata.id};
                    var success = "{:url('order/index')}";
                    //    执行异步请求 ，$.post
                    $.post(url,data,function(result){
                        if(result.status ==0){
                            layer.open({
                                content:result.message,
                                icon:2,
                                title : '错误提示'
                            });

                        }
                        if(result.status ==1){
                            layer.open({
                                content : result.message,
                                icon : 1,
                                yes : function(){
                                    location.href=success;
                                }
                            });

                        }
                    },'JSON');
                    return false;
                });
            }
            else if (obj.event === 'user') {
                layer.tips('电话:'+mdata.user_phone+'<br>'+'qq:'+mdata.user_qq+'<br>', this, {
                    tips: [1, '#3595CC'],
                    time: 4000
                });
            }
            else if (obj.event === 'developer') {
                layer.tips('姓名:'+mdata.developer_name+'<br>'+'电话:'+mdata.developer_phone+'<br>'+'QQ:'+mdata.developer_qq+'<br>'+'支付宝:'+mdata.developer_pay, this, {
                    tips: [1, '#3595CC'],
                    time: 4000
                });
            }
            else if (obj.event === 'developer1') {
                layer.tips('姓名:'+mdata.developer1_name+'<br>'+'电话:'+mdata.developer1_phone+'<br>'+'QQ:'+mdata.developer1_qq+'<br>'+'支付宝:'+mdata.developer1_pay, this, {
                    tips: [1, '#3595CC'],
                    time: 4000
                });
            }
            else if (obj.event === 'see') {
                var index = layer.open({
                    title: '订单详情',
                    type: 2,
                    shade: 0.2,
                    maxmin:true,
                    shadeClose: true,
                    area: ['60%', '80%'],
                    content: '/index.php/index/order/see?id='+mdata.id,
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
                return false;
            }
        });
        //行内点击事件
        $(document).on('click','a.first',function(){
            var id = $(this).attr("attr-id");
            var index = layer.open({
                title: '',
                type: 2,
                shade: 0.2,
                maxmin:true,
                shadeClose: true,
                area: ['60%', '80%'],
                content: '/index.php/index/order/first_pay?id='+id,
            });
            $(window).on("resize", function () {
                layer.full(index);
            });
            return false;
        });
        $(document).on('click','a.end',function(){
            var id = $(this).attr("attr-id");
            var index = layer.open({
                title: '',
                type: 2,
                shade: 0.2,
                maxmin:true,
                shadeClose: true,
                area: ['60%', '80%'],
                content: '/index.php/index/order/end_pay?id='+id,
            });
            $(window).on("resize", function () {
                layer.full(index);
            });
            return false;
        });

    });
</script>
 

</body>
</html>